<?php

//require_once('ModelConfig.php');


/**
 * Class to process log for comic.solor.cn, a singleton
 */

class Logger
{
	static private $logger = null;

	// new operation on object are not permitted 
	private function __construct() 
	{
	}

	/**
	 * make Logger instance
	 * @return the instance of Logger class
	 */
	static public function& instance()
	{
		if (self::$logger === null)
		{
			self::$logger = new Logger();
		}
		return self::$logger;
	}

	/**
	 * Write log to log file 
	 *    
	 * the log in log file will presented as :
	 *
	 *  <pre>[00000]:BasicDAO.php:556: some error</pre>
	 * 
	 * @param $log the content of your log 
	 * @param $errCode the errCode for this log
	 * @param $file the file who triger this log
	 * @param $line the line of script the log happened 
	 */
	public function log($log, $errCode = 0, $file = __FILE__, $line = __LINE__)
	{
		$errString = sprintf("[%05d]:%s:%s:", $errCode, basename($file), $line);  
		error_log($errString .$log );
	}
}
?>
